package project;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import java.awt.Font;
import javax.swing.JTextPane;
import javax.swing.UIManager;
import java.awt.Color;
import javax.swing.JList;
import javax.swing.AbstractListModel;
import javax.swing.JCheckBox;
import javax.swing.JToggleButton;
import java.awt.Choice;
import javax.swing.JButton;
import javax.swing.JRadioButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.ButtonGroup;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;


public class TestPaper {

	public JFrame frame;
	public JTextPane Question;
	public JRadioButton Section1Rb;
	public JRadioButton OptArb;
	public JRadioButton OptBrb;
	public JRadioButton OptCrb;
	public JRadioButton OptDrb;
	public JRadioButton Section2Rb;
	public ButtonGroup buttonGroup1;
	public ButtonGroup buttonGroup2;
	//private JRadioButton OptArb;
	
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					TestPaper window = new TestPaper();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
	
	public TestPaper() {
		initialize();
	}

	
	private void initialize() {
		
		buttonGroup1 = new javax.swing.ButtonGroup();
		buttonGroup2 = new javax.swing.ButtonGroup();
		
		frame = new JFrame();
		frame.setBounds(100, 100, 554, 550);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);
		
		JLabel lblIiitDelhi = new JLabel("IIIT - Delhi ");
		lblIiitDelhi.setFont(new Font("Tahoma", Font.BOLD, 16));
		lblIiitDelhi.setHorizontalAlignment(SwingConstants.CENTER);
		lblIiitDelhi.setBounds(10, 27, 518, 35);
		frame.getContentPane().add(lblIiitDelhi);
		
		JLabel lblQuestionPaper = new JLabel("Question Paper");
		lblQuestionPaper.setFont(new Font("Tahoma", Font.BOLD, 16));
		lblQuestionPaper.setHorizontalAlignment(SwingConstants.CENTER);
		lblQuestionPaper.setBounds(10, 73, 518, 35);
		frame.getContentPane().add(lblQuestionPaper);
		
		Question = new JTextPane();
		Question.setEditable(false);
		Question.setBackground(Color.WHITE);
		Question.setForeground(Color.BLACK);
		Question.setBounds(94, 152, 416, 207);
		frame.getContentPane().add(Question);
		
		JButton btnQ1 = new JButton("Q1");
		btnQ1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnQ1ActionPerformed(evt);
            }
        });
		btnQ1.setBounds(10, 152, 54, 23);
		frame.getContentPane().add(btnQ1);
		
		
		JButton btnQ2 = new JButton("Q2");
		btnQ2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnQ2ActionPerformed(evt);
            }
        });
		btnQ2.setBounds(10, 178, 54, 23);
		frame.getContentPane().add(btnQ2);
		
		
		
		JButton btnQ3 = new JButton("Q3");
		btnQ3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnQ3ActionPerformed(evt);
            }
        });
		btnQ3.setBounds(10, 204, 54, 23);
		frame.getContentPane().add(btnQ3);
		
		
		
		JButton btnQ4 = new JButton("Q4");
		btnQ4.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		btnQ4.setBounds(10, 232, 54, 23);
		frame.getContentPane().add(btnQ4);
		
		JButton btnQ5 = new JButton("Q5");
		btnQ5.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		btnQ5.setBounds(10, 259, 54, 23);
		frame.getContentPane().add(btnQ5);
		
		//buttonGroup1.add(Section1Rb);
		
		Section1Rb = new JRadioButton("Section 1");
		Section1Rb.setFont(new Font("Tahoma", Font.PLAIN, 12));
		Section1Rb.setBounds(6, 115, 86, 23);
		frame.getContentPane().add(Section1Rb);
		Section1Rb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Section1RbActionPerformed(evt);
            }
        });
		buttonGroup1.add(Section1Rb);
		
		Section2Rb = new JRadioButton("Section 2");
		Section2Rb.addPropertyChangeListener(new PropertyChangeListener() {
			public void propertyChange(PropertyChangeEvent arg0) {
			}
		});
		Section2Rb.setFont(new Font("Tahoma", Font.PLAIN, 12));
		Section2Rb.setBounds(94, 115, 86, 23);
		frame.getContentPane().add(Section2Rb);
		Section2Rb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Section2RbActionPerformed(evt);
            }
        });
		buttonGroup1.add(Section2Rb);
		
		
		OptArb = new JRadioButton("Choice A");
		OptArb.setBounds(94, 394, 109, 23);
		frame.getContentPane().add(OptArb);
		OptArb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                OptArbActionPerformed(evt);
            }
        });
		buttonGroup2.add(OptArb);
		
		
		JRadioButton OptBrb = new JRadioButton("Choice B");
		OptBrb.setBounds(320, 394, 109, 23);
		frame.getContentPane().add(OptBrb);
		OptBrb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                OptBrbActionPerformed(evt);
            }
        });
		buttonGroup2.add(OptBrb);
		
		
		JRadioButton OptCrb = new JRadioButton("Choice C");
		OptCrb.setBounds(94, 437, 109, 23);
		frame.getContentPane().add(OptCrb);
		OptCrb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            	OptCrbActionPerformed(evt);
            }
        });
		buttonGroup2.add(OptCrb);
		
		
		JRadioButton OptDrb = new JRadioButton("Choice D");
		OptDrb.setBounds(320, 437, 109, 23);
		frame.getContentPane().add(OptDrb);
		OptDrb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                OptDrbActionPerformed(evt);
            }
        });
		buttonGroup2.add(OptDrb);
		
		JButton btnNext = new JButton("Next >>");
		btnNext.setBounds(320, 478, 91, 23);
		frame.getContentPane().add(btnNext);
		
		JButton button = new JButton("<< Prev");
		button.setBounds(94, 478, 91, 23);
		frame.getContentPane().add(button);
		
	}
	private void Section1RbActionPerformed(java.awt.event.ActionEvent evt) 
	{
		Question.setText("Section 1 starts");
	}
	private void Section2RbActionPerformed(java.awt.event.ActionEvent evt) 
	{
		Question.setText("Section 2 starts");
	}
	private void OptArbActionPerformed(java.awt.event.ActionEvent evt) 
	{
		
	}
	private void OptBrbActionPerformed(java.awt.event.ActionEvent evt) 
	{
		
	}
	private void OptCrbActionPerformed(java.awt.event.ActionEvent evt) 
	{
		
	}
	private void OptDrbActionPerformed(java.awt.event.ActionEvent evt) 
	{
		
	}
	private void btnQ1ActionPerformed(java.awt.event.ActionEvent evt) 
	{
		if(Section1Rb.isSelected())
		{
			Question.setText("Hi my name is Section 1");
			
		}
		if(Section2Rb.isSelected())
		{
			Question.setText("Hi my name is Section 2");
		}
	}
	private void btnQ2ActionPerformed(java.awt.event.ActionEvent evt) 
	{
		if(Section1Rb.isSelected())
		{
			Question.setText("Question 2 in Section 1");
		}
		if(Section2Rb.isSelected())
		{
			Question.setText("Question 2 in Section 2");
		}
	}
	private void btnQ3ActionPerformed(java.awt.event.ActionEvent evt) 
	{
		if(Section1Rb.isSelected())
		{
			Question.setText("Question 3 in Section 1");
			// String ques = getQuestion(1,3);
			// Question.setText("ques");
		}
		if(Section2Rb.isSelected())
		{
			Question.setText("Question 3 in Section 2");
			// String ques = getQuestion(2,3);
			// Question.setText("ques");
		}
	}
	
	public String getQuestion(int section, int ques_no)
	{
		String a = "";
		int Q_id = (section-1)*5 + ques_no;
		
		return a;
	}
}
